#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int res=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){res=(res<<1)+(res<<3)+(c^48);c=getchar();}
	return res*f;
}
void write(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int k,m;
char c[114514],tmp[114514];
int len,n,cnt;
int main()
{
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	k=read(),m=read();
	cin>>(c+1);len=strlen(c+1);
	n=read();
	while(n--)
	{
		int l=read(),r=read(),x=read();
		cnt=0;
		for(int i=1;i<=x;i++) tmp[++cnt]=c[i];
		for(int i=l+1;i<=r;i++) tmp[++cnt]=c[i];
		for(int i=x+1;i<=len;i++) tmp[++cnt]=c[i];
		for(int i=1;i<=min(cnt,m);i++) c[i]=tmp[i];
		len=cnt;
	}
	for(int i=1;i<=k;i++) putchar(c[i]);
	return 0;
}
